package logic

import (
	"context"
	"goods_svc/goods"
	"goods_svc/internal/svc"
	"goods_svc/models/mysql"

	"github.com/zeromicro/go-zero/core/logx"
)

type CreateActivityLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCreateActivityLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateActivityLogic {
	return &CreateActivityLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 创建活动
func (l *CreateActivityLogic) CreateActivity(in *goods.CreateActivityRequest) (*goods.CreateActivityResponse, error) {
	// todo: add your logic here and delete this line

	//去mysql数据库查询一下
	activity := mysql.Activity{
		ActivityName: in.ActivityName,
		Address:      in.Address,
		Time:         in.Time,
		Name:         in.Name,
	}

	mysql.DB.Debug().Create(&activity)

	//实现创建活动
	return &goods.CreateActivityResponse{
		Id: int64(activity.ID),
	}, nil
}
